# 嵌套函数
def printName(isChinese,name,familyName):
  def inner_print(a, b):
    print("{0} {1}".format(a, b))
  if isChinese:
    inner_print(familyName,name)
  else:
    inner_print(name,familyName)


printName(True,"小七","高")
printName(False,"George","Bush")
# 高 小七
# George Bush

#测试nonlocal、global关键字的用法
a = 100

def outer():
  b = 10

  def inner():
    nonlocal b     #声明外部函数的局部变量
    print("inner b:",b)
    b = 20

    global a      #声明全局变量
    a = 1000

  inner()
  print("outer b:",b)

outer()
print("a：",a)
# inner b: 10
# outer b: 20
# a： 1000
